//
//  HUD.m
//  club
//
//  Created by zhuangyihang on 1/19/16.
//  Copyright © 2016 zhuangyihang. All rights reserved.
//

#import "HUD.h"

#import <KVNProgress/KVNProgress.h>

static const CGFloat kDismissTime = 1.5;

@interface HUD()

@end

@implementation HUD

+ (id)hud
{
    static dispatch_once_t pred = 0;
    __strong static id _sharedObject = nil;
    dispatch_once(&pred, ^{
        _sharedObject = [[self alloc] init]; // or some other init method
    });
    return _sharedObject;
}

- (UIView *)getRootView{
    UIApplication *app = [UIApplication sharedApplication];
    return app.keyWindow;
}

- (void)setupHud{
    KVNProgressConfiguration *configuration = [[KVNProgressConfiguration alloc] init];
    
//    configuration.statusColor = [UIColor whiteColor];
//    configuration.statusFont = [UIFont fontWithName:@"HelveticaNeue-Thin" size:15.0f];
//    configuration.circleStrokeForegroundColor = [UIColor whiteColor];
//    configuration.circleStrokeBackgroundColor = [UIColor colorWithWhite:1.0f alpha:0.3f];
//    configuration.circleFillBackgroundColor = [UIColor colorWithWhite:1.0f alpha:0.1f];
//    configuration.backgroundFillColor = [UIColor colorWithRed:0.173f green:0.263f blue:0.856f alpha:0.9f];
//    configuration.backgroundTintColor = [UIColor colorWithRed:0.173f green:0.263f blue:0.856f alpha:1.0f];
//    configuration.successColor = [UIColor whiteColor];
//    configuration.errorColor = [UIColor whiteColor];
//    configuration.stopColor = [UIColor whiteColor];
//    configuration.circleSize = 110.0f;
//    configuration.lineWidth = 1.0f;
//    configuration.fullScreen = NO;
//    configuration.showStop = YES;
//    configuration.stopRelativeHeight = 0.4f;
    configuration.allowUserInteraction = NO;
    
    configuration.minimumDisplayTime = 0.3;
    configuration.minimumSuccessDisplayTime = 1.0;
    configuration.minimumErrorDisplayTime = 1.0;
    
    [KVNProgress setConfiguration:configuration];
}

- (void)showNormalHUD:(NSString *)message{
    [KVNProgress showWithStatus:message];
}

- (void)dismissHUD{
    [KVNProgress dismiss];
}

- (void)showInfoHUD:(NSString *)message{
    [KVNProgress showWithStatus:message];
}

- (void)showSuccessHUD:(NSString *)message{
    [KVNProgress showSuccessWithStatus:message];
}

- (void)showErrorHUD:(NSString *)message{
    [KVNProgress showErrorWithStatus:message];
}

@end
